import { View } from '@tarojs/components';
import React from 'react';
import { DistributionWay } from '../../constants';
import styles from './index.module.scss';

const DeliveryWay = ({ product }) => {
  const { distributionWayList } = product ?? {};

  return (
    <View className={styles.DeliveryWay}>
      {distributionWayList
        ?.sort((a, b) => a - b)
        ?.map((v) => {
          switch (v) {
            case DistributionWay.post:
              return (
                <View className="delivery post" key={v}>
                  <View className="txt">直邮</View>
                </View>
              );
            case DistributionWay.takeout:
              return (
                <View className="delivery takeout" key={v}>
                  <View className="txt">外送</View>
                </View>
              );
            case DistributionWay.pickup:
              return (
                <View className="delivery pickup" key={v}>
                  <View className="txt">自提</View>
                </View>
              );
            default:
              return null;
          }
        })}
    </View>
  );
};

export default DeliveryWay;
